#include "../include/my_msq.h"
#include <string.h>

key_t key;
int msqid;

void my_msq_init(){
    key = ftok("root", 1);
    msqid = msgget(key, IPC_CREAT | 0664);
}

void my_msq_send_cmd(){
    struct cmd_msgbuf buf={.mtype=CMD_TYPE,.mtext='1'};
    msgsnd(msqid, &buf, CMD_MSGBUF_LEN, 0);
}

void my_msq_rcv_wave(unsigned int* arr){
    struct wave_msgbuf buf;
    msgrcv(msqid, &buf, WAVE_MSGBUF_LEN, WAVE_TYPE, 0);
    memcpy(arr, buf.mtext, WAVE_MSGBUF_LEN);
}